// 堆叠图
export const stacked = function(that,containerId,entryData,midData,endData){
        // 获取echarts容器 生成了echarts实例
        let myChart = that.$echarts.init(document.getElementById(containerId));
        let option = {
          title: {
            text: "成绩分析图",
          },
          tooltip: {
            trigger: "axis",
            extraCssText: "150px;height:100px",
          },
          legend: {
            top: "10%",
            data: ["入学", "期中", "期末"],
          },
          grid: {
            top: "20%",
            left: "5%",
            right: "5%",
            bottom: "5%",
            containLabel: true,
          },
          toolbox: {
            //   height: "50",
            feature: {
              saveAsImage: {},
            },
          },
          xAxis: {
            type: "category",
            boundaryGap: false,
            data: ["语文", "英语", "数学", "理综", "文综"],
          },
          yAxis: {
            type: "value",
          },
          series: [
            {
              name: "入学",
              type: "line",
            //   stack: "Total",
              data: entryData,
            },
            {
              name: "期中",
              type: "line",
            //   stack: "Total",
              data: midData,
            },
            {
              name: "期末",
              type: "line",
            //   stack: "Total",
              data: endData,
            },
          ],
        };
        myChart.setOption(option);
  
        // 当希望echarts图随着屏幕的宽度的变化而变时
        //   前提是容器的宽和高不能给具体的px 给成百分比
        window.onresize = function () {
          myChart.resize();
        };
}

// 折线图
export const basisLine = function(that,titleChart,containerId,score){
      // 获取echarts容器 生成了echarts实例
      let myChart = that.$echarts.init(document.getElementById(containerId));
      let option = {
        title: {
            text: titleChart,
          },
          grid: {
            top: "20%",
            left: "5%",
            right: "5%",
            bottom: "5%",
            containLabel: true,
          },
        xAxis: {
          type: 'category',
          data: ["入学","期中","期末"]
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: score,
            type: 'line'
          }
        ]
      };
      myChart.setOption(option);

      // 当希望echarts图随着屏幕的宽度的变化而变时
      //   前提是容器的宽和高不能给具体的px 给成百分比
      window.onresize = function () {
        myChart.resize();
      };

}
